package Leetcode;

public class Leetcode_226 {
    public static int kthGrammar(int n, int k) {
        if (n == 1) {
            return 0;
        }
        return (k & 1) ^ 1 ^ kthGrammar(n - 1, (k + 1) / 2);
    }

    public static void main(String[] args) {
        int n = 1, k = 1;
        System.out.println(kthGrammar(n,k));
    }
}
